Repositories
Insights Factory is capable of utilizing virtually any external data source in order to evaluate Insight Definition rules and render dynamic content. Those data sources can be exposed to Insights Factory through Repositories and can be used to extend Insights Factory without the need of a package release.
Repositories are a set of methods or properties contained in .NET 6 plugin assemblies. Assemblies containing Repositories are loaded by Bank Admin and Triggering Engine during application startup and their code can be used in runtime in order to:
- evaluate Insight Definition audience conditions
- evaluate Insight Definition triggering conditions
- render dynamic Insight Message content
Implementation
Repositories need to implement the IRepository
interface or IUserRepository
interface from Meniga.TriggeringEngine.Contracts.External
. Plugin assembly can contain one or more Repositories implementations.
Repositories that implement the IRepository
interface are designed to provide general dictionary data such as categories, currencies, etc. They can be used in Triggering Engine as well as in Bank Admin.
The second IUserRepository
is for repositories that operate on users. This interface contains a UserIdentity
property that indicates the user for whom the repository is invoked. There is already an abstract UserRepository
class that implements the above interface. The UserIdentity
value is passed by the constructor using the dependency injection and should be passed to this abstract class:
public class ExampleUserRepository : UserRepository
{
public ExampleUserRepository(IUserIdentityExternal userIdentity)
: base(userIdentity)
{
}
...
}
In general, all types used in Repository method signatures are placed in the main plugin assembly. However, signatures can be placed in dependent assemblies. Instructions on how to register such assemblies can be found here.
Each repository should be registered in a dependency container. This will allow repositories to be resolved by Bank Admin and Triggering Engine. Registration should be done in the appropriate installer and how to do it is described here.